<?php

namespace App\Listeners\User;

use App\Events\User\UserRegisterEvent;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;

class UserRegisterAsyncListener implements ShouldQueue
{
    /**
     * 任务连接名称。
     *
     * @var string|null
     */
    // public $connection = 'sqs';

    /**
     * 任务发送到的队列的名称.
     *
     * @var string|null
     */
    // public $queue = 'listeners';

    /**
     * 处理任务的延迟时间.
     *
     * @var int
     */
    // public $delay = 60;

    /**
     * Create the event listener.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Handle the event.
     *
     * @param  \App\Events\User\UserRegisterEvent  $event
     * @return void
     */
    public function handle(UserRegisterEvent $event)
    {
        //
        app('log')->info('异步监听UserRegisterEvent事件--');

        app('log')->info(json_encode($event));
    }

    /**
     * 确定监听器是否应加入队列
     *
     * @param  \App\Events\OrderPlaced  $event
     * @return bool
     */
    // public function shouldQueue(UserRegisterEvent $event)
    // {
    //     return $event->order->subtotal >= 5000;
    // }

    /**
     * 处理失败任务
     *
     * @param  \App\Events\OrderShipped  $event
     * @param  \Exception  $exception
     * @return void
     */
    // public function failed(OrderShipped $event, $exception)
    // {
    //     //
    // }
}
